// pages/orderPop/orderPop.js
var t = getApp();

Component({
  properties: {
    com_data: {
      type: Object,
      value: ""
    },
    apply_index: {
      type: Number,
      value: ""
    },
    status: {
      type: Number,
      value: "0"
    },
    show_com: {
      type: Number,
      value: "0"
    },
    pop_show: {
      type: Boolean,
      value: !0
    }
  },
  data: {
    cur_index: 1000,
    text: '',
    stars:[1,2,3,4,5],
    star_index: 0,
    num: "0.0",
    com_text: '',
    focus: false
  },
  ready: function(){
    var that = this;
    var isIphone=wx.getSystemInfoSync().system.indexOf("Android")>-1?false:true;
    that.setData({isIphone:isIphone})
  },
  methods: {
    return:function(){},
    close_pop:function(){
      var pop_show = !this.properties.pop_show;
      this.triggerEvent('closePop', {pop_show})
    },
    // 退款
    check_apply:function(e){
      var index=e.currentTarget.dataset.index;
      this.triggerEvent('checkApply',index)
    },
    input_apply:function(e){
      this.setData({text: e.detail.value})
    },
    input_focus:function(){
      var that=this;
      setTimeout(()=>{that.setData({focus:true})},500)
    },
    input_blur:function(){
      this.setData({focus:false})
    },
    confirm_apply:function(){
      var that=this,text=that.data.text,apply_index=this.properties.apply_index;
      var data={text:text}
      if(apply_index==1000){
        wx.showToast({
          title: '还未选择退款原因',
          icon: 'none',
          duration: 1500
        })
      }else{
        this.triggerEvent('confirmApply',{data})
        that.close_pop()
      }
    },
    // 取消排课
    cancel_work:function(){
      var data={work: false},that=this;
      this.triggerEvent('cancelWork',{data})
      that.close_pop()
    },
    // 确认排课
    confirm_work:function(){
      var data={work: true},that=this;
      this.triggerEvent('confirmWork',{data})
      that.close_pop()
    },
  },
});